﻿
' singleton that knows all !!
Public Class Navigation
    Private Shared instance As New Navigation

    Public Shared Function getInstance() As Navigation
        Return Navigation.instance
    End Function

    Private login As New LoginController

    Private menu As New MenuController

    Private kundenauswertung As New KundenauswertungController

    Private stammdatenverwaltungMenu As New StammdatenverwaltungMenuController

    Private kundenverwaltung As New KundenverwaltungController

    Private projektverwaltung As New ProjektverwaltungController

    Private taskverwaltung As New TaskverwaltungController

    Private mitarbeiterverwaltung As New MitarbeiterverwaltungController

    Private zeitrapport As New ZeitrapportController

    'historisierung für popups
    Private history As New List(Of Controller)

    Public Sub New()
        'Context.KUNDE_PROJEKT_TASK_SERVICE.initData()
    End Sub

    Private Sub fromTo(ByRef fromController As Controller, ByRef toController As Controller)
        If fromController IsNot Nothing Then
            fromController.hide()
        End If
        toController.show()
    End Sub

    Private Sub popUpTo(ByRef fromController As Controller, ByRef toController As Controller)
        toController.show()
        history.Add(fromController)
    End Sub

    Public Sub goBack(ByRef sender As Controller)
        'Dim lastindex As Integer = history.Count - 1
        'Dim toController As Controller = history(lastindex)
        'toController.setEnabled(True)
        'sender.hide()
        'history.RemoveAt(lastindex)
        'toController.show()
        sender.hide()
    End Sub

    Public Sub toLogin(ByRef sender As Controller)
        fromTo(sender, login)
    End Sub

    Public Sub toMenu(ByRef sender As Controller)
        fromTo(sender, Menu)
    End Sub

    Sub toKundenauswertung(ByRef sender As Controller)
        popUpTo(sender, kundenauswertung)
    End Sub

    Public Sub toStammdatenverwaltung(ByRef sender As Controller)
        popUpTo(sender, stammdatenverwaltungMenu)
    End Sub

    Public Sub toKundenverwaltung(ByRef sender As Controller)
        popUpTo(sender, kundenverwaltung)
    End Sub

    Public Sub toProjektverwaltung(ByRef sender As Controller)
        popUpTo(sender, projektverwaltung)
    End Sub

    Public Sub toTaskverwaltung(ByRef sender As Controller)
        popUpTo(sender, taskverwaltung)
    End Sub

    Public Sub toMitarbeiterverwaltung(ByRef sender As Controller)
        popUpTo(sender, mitarbeiterverwaltung)
    End Sub

    Public Sub toZeitrapport(ByRef sender As Controller)
        popUpTo(sender, Zeitrapport)
    End Sub
End Class
